<template>
  <div id="app">
    <transition name="slide">
      <Toast v-show="isShowToast"></Toast>
    </transition>
    <TopBar :key="topbarKeyValue"></TopBar>
    <Header></Header>
    <router-view @updateKey="updateKeyFn" />
    <Login v-show="isShowLoginModal"></Login>
    <Footer></Footer>
  </div>
</template>

<script>
// import axios from "axios";
import TopBar from "@/components/TopBar.vue";
import Header from "@/components/Header.vue";
import Footer from "@/components/Footer.vue";
import Login from "@/components/Login.vue";
import Toast from "@/components/Toast.vue";
import { mapState } from "vuex";

export default {
  data() {
    return {
      topbarKeyValue: 0,
    };
  },
  watch: {
    "$route.path": {
      handler(newVal, oldVal) {
        if (newVal != oldVal) {
          this.topbarKeyValue++;
        }
      },
    },
  },
  components: {
    TopBar,
    Header,
    Footer,
    Login,
    Toast,
  },
  methods: {
    updateKeyFn() {
      this.topbarKeyValue++;
    },
  },
  async created() {
    console.log(process.env.VUE_APP_BASE_URL);
    // axios
    // .get("http://kumanxuan1.f3322.net:8881/cms/products/recommend")
    // .then((res) => {
    // console.log("请求成功", res);
    // })
    // .catch((err) => {
    // console.log(err);
    // });
    // GetAPI()
    // .then((res) => {
    // console.log("精品数据响应....3", res);
    // })
    // .catch((err) => {
    // console.log("请求失败", err);
    // });
    // 请求精品数据
    // let res = await GetAPI();
    // console.log(res);
  },
  computed: {
    ...mapState({
      isShowLoginModal: (state) => state.showModal.isShowLoginModal,
      isShowToast: (state) => state.showToast.isShowToast,
    }),
  },
};
</script>

<style lang="less">
// #app {
// font-family: Avenir, Helvetica, Arial, sans-serif;
// -webkit-font-smoothing: antialiased;
// -moz-osx-font-smoothing: grayscale;
// text-align: center;
// color: #2c3e50;
// }
.slide-enter,
.slide-leave-to {
  opacity: 0;
}

.slide-enter-active,
.slide-leave-active {
  transition: opacity 0.3s linear;
}

.slide-enter-to,
.slide-leave {
  opacity: 1;
}
</style>
